package com.ruoyi.stock2.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock2.domain.PriceCompAverage200;
import com.ruoyi.stock2.service.IPriceCompAverage200Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2019-12-17
 */
@Controller
@RequestMapping("/stock2/AVERAGE200")
public class PriceCompAverage200Controller extends BaseController
{
    private String prefix = "stock2/AVERAGE200";

    @Autowired
    private IPriceCompAverage200Service priceCompAverage200Service;

    @RequiresPermissions("stock2:AVERAGE200:view")
    @GetMapping()
    public String AVERAGE200()
    {
        return prefix + "/AVERAGE200";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("stock2:AVERAGE200:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PriceCompAverage200 priceCompAverage200)
    {
        startPage();
        List<PriceCompAverage200> list = priceCompAverage200Service.selectPriceCompAverage200List(priceCompAverage200);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("stock2:AVERAGE200:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PriceCompAverage200 priceCompAverage200)
    {
        List<PriceCompAverage200> list = priceCompAverage200Service.selectPriceCompAverage200List(priceCompAverage200);
        ExcelUtil<PriceCompAverage200> util = new ExcelUtil<PriceCompAverage200>(PriceCompAverage200.class);
        return util.exportExcel(list, "AVERAGE200");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("stock2:AVERAGE200:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PriceCompAverage200 priceCompAverage200)
    {
        return toAjax(priceCompAverage200Service.insertPriceCompAverage200(priceCompAverage200));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{symbol}")
    public String edit(@PathVariable("symbol") String symbol, ModelMap mmap)
    {
        PriceCompAverage200 priceCompAverage200 = priceCompAverage200Service.selectPriceCompAverage200ById(symbol);
        mmap.put("priceCompAverage200", priceCompAverage200);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("stock2:AVERAGE200:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PriceCompAverage200 priceCompAverage200)
    {
        return toAjax(priceCompAverage200Service.updatePriceCompAverage200(priceCompAverage200));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("stock2:AVERAGE200:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(priceCompAverage200Service.deletePriceCompAverage200ByIds(ids));
    }
}
